Skip to content

The server can export its job queue size and oldest wait per base over OpenTelemetry - #1540

Open
gedaiu wants to merge 4 commits into
deeplethe:devfrom
re-cinq:feat/opentelemetry
Open

gedaiu wants to merge 4 commits into
deeplethe:devfrom
re-cinq:feat/opentelemetry

Conversation

@gedaiu

@gedaiu gedaiu commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Hi! This is the first of the three PRs for #1539: the setup and both queue gauges. #1541 is folded in, as suggested on #1539.

When OTEL_EXPORTER_OTLP_ENDPOINT is set, the server sends its traces and metrics over OTLP. When it is not set, nothing changes and the logs look exactly as before.

  • utopia.jobs.queue.size is the number of due queued and running jobs per base, lane and status. One grouped query refreshes it every 30 seconds. A retry that is not due yet is left out, the same way the worker skips it. A job is placed in its base through its kb_id, document or source, and a malformed kb_id lands under "none" instead of failing the count.
  • utopia.jobs.queue.oldest_wait is how long, in seconds, the oldest due queued job of each base, lane and status has waited. It reads from the same snapshot, so it adds no query.
  • The transport follows the standard OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf by default, as the OTel spec asks, or grpc. OTEL_TRACES_EXPORTER=none keeps metrics only. Together they let the server push straight into Prometheus's own OTLP receiver (--web.enable-otlp-receiver), which takes HTTP and no traces. I checked that against Prometheus 3.5 locally, and both queue gauges arrived.
  • The OTel layer has its own filter, info by default and overridable with UTOPIA_OTEL_FILTER. The global EnvFilter now applies to stdout only, so utopia=debug spans stay in the log and are not exported.

Tests: one in-memory exporter test per gauge, one for the refresh against the database, one checking that a debug span stays out of the export, and three for reading the endpoint.

I checked it against a local collector and both gauges showed up as expected. Model calls and job outcomes come next, as their own PRs against dev. Thanks for taking a look!

…when OTEL_EXPORTER_OTLP_ENDPOINT is set (deeplethe#1539)

Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
…ane and status (deeplethe#1539)

Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
@WaylandYang

Copy link
Copy Markdown
Contributor

Thanks! I answered on #1539 with a suggestion to simplify the whole stack: drop kb from the model-call and job metrics so no call site needs editing, keep task bounded, and fold the seven PRs into three. For this one, please fold #1541 into it and give the OTel layer its own filter.

…s otherwise (deeplethe#1539)

utopia=debug stays a stdout setting: the global EnvFilter now applies to the
fmt layer only, so debug spans are no longer exported. One exporter test per
metric is kept.
@gedaiu gedaiu changed the title The server can export its job queue size per base over OpenTelemetry The server can export its job queue size and oldest wait per base over OpenTelemetry Nov 29, 2026
@gedaiu
gedaiu marked this pull request as ready for review November 29, 2026 16:18
…TER=none keeps metrics only (deeplethe#1539)

http/protobuf is the default, as the OTel spec asks, and grpc stays one
variable away. Prometheus's own OTLP receiver takes HTTP and no traces, so
both are needed to push metrics straight to it.
gedaiu added a commit to re-cinq/utopia that referenced this pull request Nov 30, 2026
The server can push its metrics to Prometheus over OTLP/HTTP (upstream deeplethe#1540)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants